﻿using UnityEngine;
using System.Collections;

public class Game : MonoBehaviour {

	public GameObject player;
	public PlayerHealth plrhp;
	public PlayerMovement plrmove;
	
	
	public GameObject generator;
	GridGenerator ggen;
	
	public int increase = 1;
	public static int starting_difficulty = 0;
	
	public bool player_dead = false;
	public float death_delay = 2f;

	// Use this for initialization
	void Start () {
		ggen = generator.GetComponent<GridGenerator>();
		
		starting_difficulty+=increase;
		ggen.level_difficulty=starting_difficulty;
		
		plrhp=player.GetComponent<PlayerHealth>();
		plrmove=player.GetComponent<PlayerMovement>();
		
		//Screen.lockCursor = true;
	}
	
	
	void OnGUI()
	{

	}
	
	// Update is called once per frame
	void Update () {
	
		if(PlayerHealth.hp<=0f)
			player_dead=true;
	
		if(player_dead && death_delay>0f)
		{
			death_delay-=Time.deltaTime;
		}
		
		if(player_dead && death_delay<=0f)
		{
		/*
			GameObject new_player = null;
			new_player = Instantiate(player,start_pos.position,start_pos.rotation)as GameObject;
		*/
			plrhp.ResetStats();
				
			player_dead = false;
			death_delay = 2f;
		}
	}
}
